<template>
	<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
			
		  <el-form-item label="员工编号" prop="eno">
			<el-input v-model="ruleForm.eno"></el-input>
		  </el-form-item>
		  <el-form-item label="员工姓名" prop="ename">
			<el-input v-model="ruleForm.ename"></el-input>
		  </el-form-item>
		  <el-form-item label="员工密码" prop="epassword">
			<el-input v-model="ruleForm.epassword"></el-input>
		  </el-form-item>
		  <el-form-item label="员工级别" prop="elevel">
			<el-input v-model="ruleForm.elevel"></el-input>
		  </el-form-item>
		  <el-form-item label="员工电话" prop="ephone">
			<el-input v-model="ruleForm.ephone"></el-input>
		  </el-form-item>
		  </el-form-item>
		  <el-form-item label="员工工资" prop="esalary">
		  			<el-input v-model="ruleForm.esalary"></el-input>
		  </el-form-item>
		  <el-form-item label="备注" prop="eremark">
			<el-input v-model="ruleForm.eremark"></el-input>
		  </el-form-item>
		  

		  <el-form-item>
			<el-button type="primary" @click="submitForm('ruleForm')">新建信息</el-button>
			 <el-button @click="resetForm('ruleForm')">重置</el-button>
		  </el-form-item>
	</el-form>
</template>
<script>
  export default {
	  name: "EmployeeAdd",
			data() {
			  return {
				ruleForm: {
				  eno:'',
				  ename:'',
				  epassword:'',
				  elevel:'',
				  ephone:'',
				  esalary:'',
				  eremark:'' 
				},
				rules: {
						
				}
			  };
			},
			methods: {
			 submitForm(formName) {
				 const _this = this;
			         this.$refs[formName].validate((valid) => {
			           if (valid) {
							axios.post('http://localhost:8181/employee/save',this.ruleForm).then(function(resp){
								console.log(resp)
								if(resp.data == 'success'){
									_this.$message('添加成功！');
									_this.$router.push('/EmployeeSearch')
								}
							})
			           } else {
			             console.log('error submit!!');
			             return false;
			           }
			         });
			       },
			       resetForm(formName) {
			         this.$refs[formName].resetFields();
			       }
			     }
		  }
</script>
